package com.liangwj.springbootdesignpatterns.structureTypePatterns.composite.demo_2;

import java.math.BigDecimal;
import java.util.List;

/**
 * <b>Description:</b> 树枝构建: 树节点类, 可以对分支节点进行增删改查操作 <br/>
 * @author Lingwenjun
 * @date 2019/1/28-16:04
 * @version 1.0
 */
public class ConcreateCompany extends Company{

    //
    public ConcreateCompany(String name, String sex, String position, BigDecimal salary) {
        this.name = name;
        this.sex = sex;
        this.position = position;
        this.salary = salary;
    }

    /**
     * 增加: 添加应给枝节点 company 为实例化的的子类
     * @param company
     */
    public void add(Company company) {
        list.add(company);
    }

    /**
     * 删除子节点
     * @param company
     */
    public void remove(Company company) {
        list.remove(company);
    }

    /**
     * 返回所有子节点
     * @return
     */
    public List<Company> getChild() {
        return list;
    }

    @Override
    public String getInfo() {
        StringBuilder sb = new StringBuilder();
        sb.append("领导 : ");
        sb.append("名称:");
        sb.append(name);
        sb.append(", 性别:");
        sb.append(sex);
        sb.append(", 职位:");
        sb.append(position);
        sb.append(", 薪水:");
        sb.append(salary);
        return sb.toString();
    }
}
